package sicau.carManager.Util.SendMessage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.client.RestTemplate;



/**
 * @Author ITcz
 * @Data 2021-05-24 - 12:33
 */

public class SendMsgUtil {

    @Autowired
    static RestTemplate restTemplate;

    static final String LoginName = "YACN001";

    static final String Password = "UYi@45wa";

    /**
    * 套餐,2为A套餐
    * */
    static final int FeeType = 2;

    static final String SignName = "【智慧川农】";

    /**
     *定时时间为空，即立刻发送
     */
    static final String TimingDate = "";

    /**
    * 不管这个参数
    * */
    static final String ExtCode = "";

    /**
    * 短信内容，通過接口传入
    * */
    static final String Content = "";

    /**
    * 给静态RestTemplate变量赋值
    * */
    private void setRestTemplate(@Autowired RestTemplate restTemplate) {
        SendMsgUtil.restTemplate = restTemplate;
    }

    /**
     * count：违章信息发送的次数
     * licensePlate：违章车牌号
     * */
    public static String createMsg(int count, String licensePlate){

        //获取短信内容
        return ContentEnum.createContent(count, licensePlate);
    }

    /**
    * count：车辆违章的次数
     * licensePlate：违章车牌号
    * */
    public static String sendMsg(String content, String mobile){

        String requestUrl = "https://sdkulink.028lk.com:8082/Api/SendSms?LoginName="+LoginName+"&Pwd="+Password+
                "&FeeType="+FeeType+"&Mobile="+mobile+"&Content="+content+"&SignName="+SignName+"&TimingDate="+TimingDate+"&ExtCode="+ExtCode+"";
        final String responseObject = restTemplate.getForObject(requestUrl, String.class);

        return responseObject;
    }

}
